package model.cardData;

import java.util.ArrayList;
	
public class Card {
	
	private CardValue cardValue;
	private CardSuit cardSuit;
	private ArrayList <CardValue> playable;
	
	public Card(CardValue cv, CardSuit cs) {
		this.cardValue = cv;
		this.cardSuit = cs;
		generatePlayable();
	}
	
	public CardValue getCardValue() {
		return cardValue;
	}
	
	public CardSuit getCardSuit() {
		return cardSuit;
	}
	
	public ArrayList<CardValue> getPlayable() {
		return playable;
	}
	
	private void generatePlayable() {
		playable = new ArrayList<CardValue>();
		
		switch (CardParameters.requestDamnRule(cardValue)) {
		case NOSP:
		case SKIP: //Aussetzenkarte, bei den drauflegbaren Karten wie normale Karte //TODO: Aussetzen in Spiellogik
			for(CardValue other : CardValue.values()) {
				if(other.compareTo(cardValue)>=0 || 
						CardParameters.is(CardRule.INVISIBLE, other) || 
						CardParameters.is(CardRule.RESTART, other)) {
					
					playable.add(other);
					
				}
			}
			break;
		case UNDER:
			for(CardValue other : CardValue.values()) {
				if(other.compareTo(cardValue)<=0 || 
						CardParameters.is(CardRule.INVISIBLE, other) || 
						CardParameters.is(CardRule.RESTART, other)) {
					
					playable.add(other);
					
				}
			}
			break;
		case RESTART:
			for(CardValue other : CardValue.values()) {
				playable.add(other);
			}
			break;
		default: //TODO: Invisible: in der Spiellogik dann, kann hier nicht betrachtet werden
			break;
		}
	}
	
}
